import {
    _decorator,
    Button,
    Component,
    director,
    instantiate,
    Label,
    Layout,
    Node,
    Prefab,
    ProgressBar,
    resources,
    tween
} from 'cc';
import {userInfo} from '../../user-info';
import {HeadComp} from '../mainui/head-comp';
import {showAlert} from '../alert/alert';
import {GameEvent} from '../../game-event';
import {Peculiarity} from "db://assets/script/game/skills/peculiarity";
import {FishStatus} from '../../../proto/shared/v1/biz';
import {BattleInfo, BattleInfo_FinalBattleInfo, FreshImmortal} from "db://assets/proto/shared/v1/wuni";
import {serverTimeHelper} from "db://assets/script/server-time-helper";
import {configsHelper} from "db://assets/script/configs-helper";
import {fishUtils} from "db://assets/script/utils/fish-utils";
import {UserFishRefineEvent} from "db://assets/script/common/events/fish-events/user-fish-refine-event";
import {FishSleepEvent} from "db://assets/script/common/events/fish-events/fish-sleep-event";
import {lobby} from "db://assets/script/lobby";
import {PropBag} from "db://assets/script/game/mainui/props/prop-bag";
import {BagType} from "db://assets/script/game/constants/bag-type";
import Long from "long";
import {ZoneMapPlane} from "db://assets/script/game/mainui/battle/zone-map-plane";
import {FishAliveDurationSelector} from "db://assets/script/game/mainui/battle/fish-alive-duration-selector";
import {UserFishReceiveBagEvent} from "db://assets/script/common/events/fish-events/user-fish-receive-bag-event";
import {FishAliveEvent} from "db://assets/script/common/events/fish-events/fish-alive-event";
import {RadarChart} from "db://assets/script/game/mainui/radar-chart";
import maxNormalHealth = fishUtils.maxNormalHealth;
import maxMagicPower = fishUtils.maxMagicPower;
import {cmm} from "db://assets/script/utils/cmm";
import {textUtils} from "db://assets/script/utils/text-utils";

const {ccclass, property} = _decorator;

@ccclass('FishAttrsDetails')
export class FishAttrsDetails extends Component {

    @property(Label)
    physicalAttack!: Label
    @property(Label)
    goldAttack!: Label
    @property(Label)
    woodAttack!: Label
    @property(Label)
    waterAttack!: Label
    @property(Label)
    fireAttack!: Label
    @property(Label)
    earthAttack!: Label

    @property(Label)
    physicalDefense!: Label
    @property(Label)
    goldDefense!: Label
    @property(Label)
    woodDefense!: Label
    @property(Label)
    waterDefense!: Label
    @property(Label)
    fireDefense!: Label
    @property(Label)
    earthDefense!: Label


    @property(Label)
    normalHealth!: Label
    @property(Label)
    normalSelfHealing!: Label
    @property(Label)
    magicPower!: Label
    @property(Label)
    absorption!: Label


    @property(Label)
    dodge!: Label
    @property(Label)
    critical!: Label
    @property(Label)
    lifeSteal!: Label
    @property(Label)
    attackInterval!: Label

    @property(Label)
    physicalCriticalDamage!: Label
    @property(Label)
    goldCriticalDamage!: Label
    @property(Label)
    woodCriticalDamage!: Label
    @property(Label)
    waterCriticalDamage!: Label
    @property(Label)
    fireCriticalDamage!: Label
    @property(Label)
    earthCriticalDamage!: Label

    start() {
    }

    init(battleInfo: BattleInfo_FinalBattleInfo) {
        this.physicalAttack.string = textUtils.longToTenThousand(battleInfo.physicalAttack)
        this.goldAttack.string = textUtils.longToTenThousand(battleInfo.goldAttack)
        this.woodAttack.string = textUtils.longToTenThousand(battleInfo.woodAttack)
        this.waterAttack.string = textUtils.longToTenThousand(battleInfo.waterAttack)
        this.fireAttack.string = textUtils.longToTenThousand(battleInfo.fireAttack)
        this.earthAttack.string = textUtils.longToTenThousand(battleInfo.earthAttack)
        this.physicalDefense.string = textUtils.longToTenThousand(battleInfo.physicalDefense)
        this.goldDefense.string = textUtils.longToTenThousand(battleInfo.goldDefense)
        this.woodDefense.string = textUtils.longToTenThousand(battleInfo.woodDefense)
        this.waterDefense.string = textUtils.longToTenThousand(battleInfo.waterDefense)
        this.fireDefense.string = textUtils.longToTenThousand(battleInfo.fireDefense)
        this.earthDefense.string = textUtils.longToTenThousand(battleInfo.earthDefense)
        this.normalHealth.string = textUtils.longToTenThousand(battleInfo.normalHealth)
        this.normalSelfHealing.string = textUtils.longToTenThousand(battleInfo.normalSelfHealing)
        this.magicPower.string = textUtils.longToTenThousand(battleInfo.magicPower)
        this.absorption.string = textUtils.longToTenThousand(battleInfo.absorption)
        this.dodge.string = (Math.floor(battleInfo.dodge.toNumber() / 100)).toFixed(2) + '%'
        this.critical.string = (Math.floor(battleInfo.critical.toNumber() / 100)).toFixed(2) + '%'
        this.lifeSteal.string = (Math.floor(battleInfo.lifeSteal.toNumber() / 100)).toFixed(2) + '%'
        this.attackInterval.string = (Math.floor(100000 / battleInfo.attackInterval.toNumber()) / 100).toString()
        this.physicalCriticalDamage.string = (Math.floor(battleInfo.physicalCriticalDamage.add(15000).toNumber() / 100)).toFixed(2) + '%'
        this.goldCriticalDamage.string = (Math.floor(battleInfo.goldCriticalDamage.add(15000).toNumber() / 100)).toFixed(2) + '%'
        this.woodCriticalDamage.string = (Math.floor(battleInfo.woodCriticalDamage.add(15000).toNumber() / 100)).toFixed(2) + '%'
        this.waterCriticalDamage.string = (Math.floor(battleInfo.waterCriticalDamage.add(15000).toNumber() / 100)).toFixed(2) + '%'
        this.fireCriticalDamage.string = (Math.floor(battleInfo.fireCriticalDamage.add(15000).toNumber() / 100)).toFixed(2) + '%'
        this.earthCriticalDamage.string = (Math.floor(battleInfo.earthCriticalDamage.add(15000).toNumber() / 100)).toFixed(2) + '%'
    }
}